/*
*	This file contains the definition of the game's board
*/

#ifndef _GAMEBOARD_
#define _GAMEBOARD_

#include <vector>

#include "Tile.h"
#include "Entity.h"
#include "MoveInfo.h"
#include "Common.h"

class GameBoard
{

public:
	GameBoard(int width, int height, int canvasWidth, int canvasHeight);
	virtual ~GameBoard();
	bool GenerateBoard();

	// info is an out param
	void GetMoveInfo(Entity * ent, MoveDirection dir, MoveInfo &info);

	void Render();

	// translate a worldspace location to a row/column
	void TranslateLocationToRowCol(const Position &pos, Position &outRowCol);

	// translate a row column to a worldspace location
	void TranslateRowColToLocation(const Position &outRowCol, Position &pos);

	// get's the tile at the row/col passed
	Tile* GetTile(const Position &rowCol);

	// notifies a tile that it has been "consumed"
	bool ConsumeTileForMove(const MoveInfo &m);
	
private:
	int m_height;
	int m_width;

	int m_tileHeight;
	int m_tileWidth;
	bool m_initialized;
	std::vector<std::vector<Tile *>> m_tiles;

	void freeResources();

	// populates the moveinfo object
	void populateMoveInfo(MoveInfo &info);

	// modifies the rowcol passed based on the direction passed
	void getDestinationRowCol(const MoveDirection &dir, Position &rowCol); 
};

#endif //_GAMEBOARD_